package com.lee.dutylower.domain;

import android.support.annotation.NonNull;

import com.lee.dutylower.db.greenEntity.Soldier;

import java.util.Comparator;

/**
 * Created by lijie on 2017/8/7.
 */

public class SoldierComparator implements Comparator<Soldier> {
    @Override
    public int compare(@NonNull Soldier so1,@NonNull Soldier so2) {
        if (so1.getSentryGroup().size()!=0 || so2.getSentryGroup().size()!=0){
            if( (so1.getSentryGroup().size()-so2.getSentryGroup().size()) == 0){
                if ((so1.getGuardTimes() - so2.getGuardTimes())==0){
                    return (int) (so2.getSID() - so1.getSID());
                }
                return so1.getGuardTimes() - so2.getGuardTimes();
            }else {

                return so1.getSentryGroup().size()-so2.getSentryGroup().size();
            }
        }else {
            if ((so1.getGuardTimes() - so2.getGuardTimes())==0){
                return (int) (so2.getSID() - so1.getSID());
            }
            return so1.getGuardTimes() - so2.getGuardTimes();
        }
    }
}
